<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <meta content="width=device-width,initial-scale=1.0" name="viewport">
    <script type="text/javascript" src="/config.js"></script>
    <link href="/logo.svg" rel="icon">
</head>

<style>
    .app-loading {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        background: #fff;
    }

    .app-loading__logo {
        margin-bottom: 30px;
    }

    .app-loading__logo img {
        width: 90px;
        vertical-align: bottom;
    }

    .app-loading__loader {
        box-sizing: border-box;
        width: 35px;
        height: 35px;
        border: 5px solid transparent;
        border-top-color: #000;
        border-radius: 50%;
        animation: .5s loader linear infinite;
        position: relative;
    }

    .app-loading__loader:before {
        box-sizing: border-box;
        content: '';
        display: block;
        width: inherit;
        height: inherit;
        position: absolute;
        top: -5px;
        left: -5px;
        border: 5px solid #ccc;
        border-radius: 50%;
        opacity: .5;
    }

    .app-loading__title {
        font-size: 24px;
        color: #333;
        margin-top: 30px;
    }

    .dark .app-loading {
        background: #222225;
    }

    .dark .app-loading__loader {
        border-top-color: #fff;
    }

    .dark .app-loading__title {
        color: #d0d0d0;
    }

    @keyframes loader {
        0% {
            transform: rotate(0deg);
        }
        100% {
            transform: rotate(360deg);
        }
    }
</style>
<body>
<noscript>
    <strong>We're sorry but Mate Admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<script type="text/javascript">
    var dark = window.localStorage.getItem('appDark');
    if (dark) {
        document.documentElement.classList.add("dark")
    }
</script>
<div id="app" class="adminui">
    <div class="app-loading">
        <div class="app-loading__logo">
            <img src="/logo.svg" alt="logo"/>
        </div>
        <div class="app-loading__loader"></div>
        <div class="app-loading__title">加载中...</div>
    </div>
</div>
<!-- built files will be auto injected -->
<script src="./src/main.ts" type="module"></script>
<script type="text/javascript">
    // 转驼峰
    String.prototype.toCamelCase = function () {
        if (this) {
            return this.replace(/[\/._-](\w)/g, (all, letter) => letter.toUpperCase());
        } else {
            return this;
        }
    }
    // 是否为链接地址
    String.prototype.isLink = function () {
        // return /^http[s]?:\/\/.*/.test(this);
        return /(((^https?:(?:\/\/)?)(?:[-:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&%@.\w_]*)#?(?:[\w]*))?)$/.test(this);
    }

    // 是否为邮箱号
    String.prototype.isEmail = function () {
        return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(this);
    }

    // 是否为手机号
    String.prototype.isPhone = function () {
        return /^1[0-9]{10}$/.test(this) || /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(this);
    }

    // 是否为车牌号
    String.prototype.isCarNumber = function () {
        return /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/.test(this);
    }

    // 获取数组第一个元素
    Array.prototype.first = function () {
        if (this.length) return this[0];
    }

    // 获取数组最后一个元素
    Array.prototype.last = function () {
        if (this.length) return this[this.length - 1];
    }

    // 层级数据扁平化
    Array.prototype.flatten = function (property = 'children') {
        if (this.length) {
            return this.reduce((result, item) => {
                let arr = item.hasOwnProperty(property) && Array.isArray(item[property]) && item[property].length > 0 ? item[property].flatten() : [];
                return result.concat(item, arr);
            }, [])
        }
    }
</script>
</body>
<div id="versionCheck" style="display: none;position: absolute;z-index: 99;top:0;left:0;right:0;bottom:0;padding:40px;background:rgba(255,255,255,0.9);color: #333;">
    <h2 style="line-height: 1;margin: 0;font-size: 24px;">当前使用的浏览器内核版本过低 :(</h2>
    <p style="line-height: 1;margin: 0;font-size: 14px;margin-top: 20px;opacity: 0.8;">当前版本：<span id="versionCheck-type">--</span> <span id="versionCheck-version">--</span></p>
    <p style="line-height: 1;margin: 0;font-size: 14px;margin-top: 10px;opacity: 0.8;">最低版本要求：Chrome 71+、Firefox 65+、Safari 12+、Edge 97+。</p>
    <p style="line-height: 1;margin: 0;font-size: 14px;margin-top: 10px;opacity: 0.8;">请升级浏览器版本，或更换现代浏览器，如果你使用的是双核浏览器,请切换到极速/高速模式。</p>
</div>
<script type="text/javascript">
    function getBrowerInfo() {
        var userAgent = window.navigator.userAgent;
        var browerInfo = {
            type: 'unknown',
            version: 'unknown',
            userAgent: userAgent
        };
        if (document.documentMode) {
            browerInfo.type = "IE"
            browerInfo.version = document.documentMode + ''
        } else if (indexOf(userAgent, "Firefox")) {
            browerInfo.type = "Firefox"
            browerInfo.version = userAgent.match(/Firefox\/([\d.]+)/)[1]
        } else if (indexOf(userAgent, "Opera")) {
            browerInfo.type = "Opera"
            browerInfo.version = userAgent.match(/Opera\/([\d.]+)/)[1]
        } else if (indexOf(userAgent, "Edg")) {
            browerInfo.type = "Edg"
            browerInfo.version = userAgent.match(/Edg\/([\d.]+)/)[1]
        } else if (indexOf(userAgent, "Chrome")) {
            browerInfo.type = "Chrome"
            browerInfo.version = userAgent.match(/Chrome\/([\d.]+)/)[1]
        } else if (indexOf(userAgent, "Safari")) {
            browerInfo.type = "Safari"
            browerInfo.version = userAgent.match(/Safari\/([\d.]+)/)[1]
        }
        return browerInfo
    }

    function indexOf(userAgent, brower) {
        return userAgent.indexOf(brower) > -1
    }

    function isSatisfyBrower() {
        var minVer = {
            "Chrome": 71,
            "Firefox": 65,
            "Safari": 12,
            "Edg": 97,
            "IE": 999
        }
        var browerInfo = getBrowerInfo()
        var materVer = browerInfo.version.split('.')[0]
        return materVer >= minVer[browerInfo.type]
    }

    if (!isSatisfyBrower()) {
        document.getElementById('versionCheck').style.display = 'block';
        document.getElementById('versionCheck-type').innerHTML = getBrowerInfo().type;
        document.getElementById('versionCheck-version').innerHTML = getBrowerInfo().version;
    }
</script>
</html>
